package com.moranyunxi.www.pojo;

import lombok.Data;

@Data
public class ResultJson {

    private int code;

    private String msg;

    private Object data;

    public ResultJson() {

    }

    public ResultJson(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResultJson(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static ResultJson ok() {
        return new ResultJson(ReturnTemplate.SUCCESS.getCode(), ReturnTemplate.SUCCESS.getMessage());
    }

    public static ResultJson ok(Object data) {
        return new ResultJson(ReturnTemplate.SUCCESS.getCode(), ReturnTemplate.SUCCESS.getMessage(), data);
    }

    public static ResultJson paramaterException() {
        return new ResultJson(ReturnTemplate.PARAMATER_EXCEPTION.getCode(), ReturnTemplate.PARAMATER_EXCEPTION.getMessage());
    }

    public static ResultJson serverError() {
        return new ResultJson(ReturnTemplate.SERVER_ERROR.getCode(), ReturnTemplate.SERVER_ERROR.getMessage());
    }

    public static ResultJson exception(String msg) {
        return new ResultJson(ReturnTemplate.SERVER_ERROR.getCode(), msg);
    }
}
